package com.sunwayworld.basemodule.basedata.pageconfig.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.basedata.pageconfig.dao.LimsPageContentConfigDao;
import com.sunwayworld.basemodule.basedata.pageconfig.bean.LimsPageContentConfigBean;
import com.sunwayworld.basemodule.basedata.pageconfig.service.LimsPageContentConfigService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsPageContentConfigServiceImpl implements LimsPageContentConfigService {

    @Autowired
    private LimsPageContentConfigDao limsPageContentConfigDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsPageContentConfigDao getDao() {
        return limsPageContentConfigDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsPageContentConfigBean limsPageContentConfig = jsonWrapper.parseUnique(LimsPageContentConfigBean.class);
        limsPageContentConfig.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsPageContentConfig);
        return limsPageContentConfig.getId();
    }

}
